package rm.metrology.shared;

import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;

public enum CalibrationEnum {

	MASS("Mass"), 
	VOLUME("Volume"), 
	LENGTH("Length");
	
	private String fName;
	
	private static List<String> fUnmodifiableEnumNames;
	
	private CalibrationEnum(String name) {
		fName = name;
	}
	
	@Override
	public String toString() {
		return fName;
	}
	
	public static CalibrationEnum toEnum(String name) {
		for (CalibrationEnum t : EnumSet.allOf(CalibrationEnum.class)) {
			if (t.toString().equalsIgnoreCase(name)) {
				return t;
			}
		}
		throw new IllegalArgumentException("CalibrationType Invalid: " + name);
	}
	
	public static List<String> toEnumNames() {
		if (fUnmodifiableEnumNames == null) {
			List<String> tmpList = new ArrayList<String>();
			for (CalibrationEnum t : EnumSet.allOf(CalibrationEnum.class)) {
				tmpList.add(t.toString());
			}
			fUnmodifiableEnumNames = Collections.unmodifiableList(tmpList); 
		}
		return fUnmodifiableEnumNames;
	}
	
}
